* ======================================
* --------- Distributions Size ---------
* ======================================


	use "$dta\EstimationSample.dta", clear

	gen one = 1
	keep if year == 2015
	
	
* Panel A: Family
* ===============
		
	preserve
	
	* Compute size
	rename Voter_id idPers
	merge 1:m idPers using $dta\NetworkFam2.dta, keep(matched) ///
		keepusing(Family) nogen 
	gen close = 1*(Family >=1 & Family  <= 3)
	gen extended = 1*(Family >=1 & Family  <= 8)
	collapse (sum) close extended, by(idPers)
	replace close = 50 if close > 50
	replace extended = 50 if extended > 50
	
	* Narrow
	hist close, width(2) start(0) scheme(plotplain) title(Close) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(fam1_v, replace)
		
	* Broad	
	hist extended, width(2) start(0) scheme(plotplain) title(Extended) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(fam2_v, replace)
	restore
	
	graph combine fam1_v fam2_v, row(1) scheme(plotplain) ///
		title(Panel A: Family, size(medium)) ycommon name(fam_v, replace)	
	
	
* Panel B: Co-workers
* ===================	

	* Narrow
	preserve
	keep if Work1 == 1
	qui collapse (sum) one, by(Work1net)
	replace one = 50 if one > 50
	hist one, width(2) start(0) scheme(plotplain) title(Age-establishment) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(work1_v, replace)
	restore
	
	* Broad
	preserve
	keep if Work2 == 1
	qui collapse (sum) one, by(Work2net)
	replace one = 50 if one > 50
	hist one, width(2) start(0) scheme(plotplain) title(Establishment) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(work2_v, replace)
	restore


	graph combine work1_v work2_v, row(1) scheme(plotplain) ///
		title(Panel B: Co-workers, size(medium)) ycommon name(work_v, replace)	
	
	
* Panel C: Immigrants
* ===================

	* Narrow
	preserve
	keep if Imm1 == 1
	qui collapse (sum) one, by(Imm1net)
	replace one = 50 if one > 50
	hist one, width(2) start(0) scheme(plotplain) title(3-digit) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(imm1_v, replace) 
	restore

	* Broad
	preserve
	keep if Imm2 == 1
	qui collapse (sum) one, by(Imm2net)
	replace one = 50 if one > 50
	hist one, width(2) start(0) scheme(plotplain) title(2-digit) ///
		ytitle(Density) xlab(0(10)40 50 "50+") xtitle(Network size) ///
		name(imm2_v, replace)
	restore

	graph combine imm1_v imm2_v, row(1) scheme(plotplain) ///
		title(Panel C: Immigrants, size(medium)) ycommon name(imm_v, replace)	


		
* Size distributions
* ==================
	
	graph combine fam_v work_v imm_v, col(1) scheme(plotplain) ysize(8)
	graph export "$figs\DistributionsSize.pdf", replace

